home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 235 / Issue 235 - September 2007 - DPCS0907DVD.ISO / Microsoft / Expression Blend / Blend.en.msi / Microsoft.Expression.InteractiveDesigner.Help.en / interop / concept_debugging.htm < prev    next >
Encoding:
Extensible Markup Language  |  2007-03-23  |  16.6 KB  |  276 lines

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
  5. <link rel="stylesheet" type="text/css" href="../main/blend_v1.css" />
  6. <title>Debugging Expression Blend applications</title>
  7. </head>
  8. <table width="100%" cellspacing="0" cellpadding="0">
  9.     <tr>
  10.         <td class="bannercontent" height="97" width="495">
  11.         <table width="278px" cellspacing="0" cellpadding="0" align="left">
  12.             <tr>
  13.                 <td class="bannertable" width="226px"><A href="../home.htm">
  14.                 <img height="30px" width="119" alt="Content" src="../main/1pix.gif" border="0"/></A></td>
  15.                 <td class="bannertable" width="188px"><A href="../index.htm">
  16.                 <img height="30px" width="90" alt="Index" src="../main/1pix.gif" border="0"/></A></td>
  17.                 <td class="bannertable" width="188px"><A href="../search.htm">
  18.                 <img height="30px" width="90" alt="Search" src="../main/1pix.gif" border="0"/></A></td>
  19.             </tr>
  20.         </table>
  21.         </td>
  22.         <td class="bannerphotoscope"> </td>
  23.     </tr>
  24. </table>
  25.  
  26. <div id="container">
  27.  
  28. <div id="breadcrumb">
  29.         <div id="backforward">
  30.         <a href="javascript:window.history.back(-1)" onmouseover="image1.src='../main/back_active.png';"
  31.         onmouseout="image1.src='../main/back_disabled.png';">
  32.         <img alt="Back" name="image1" src="../main/back_disabled.png" border=0></a>    
  33.  
  34.         <a href="javascript:window.history.forward(1)" onmouseover="image2.src='../main/forward_active.png';"
  35.         onmouseout="image2.src='../main/forward_disabled.png';">
  36.         <img alt="Forward" name="image2" src="../main/forward_disabled.png" border=0></a>
  37.         </div>
  38.  
  39. <a href="../home.htm">Home</a> > 
  40. <a href="../your_work/dc_yourwork.htm">Managing your projects</a> > Debugging Expression Blend applications
  41.                     
  42.     <div style="float:right"><a href="javascript:window.print();">Print this page</a></div>
  43.  
  44. </div>
  45.  
  46. <div id="content">
  47. <h1>Debugging Expression Blend applications</h1>
  48.  
  49. <ul class="miniTOC">
  50.     <li><a href="#syntax">Syntax errors</a></li>
  51.     <li><a href="#compile">Compilation errors</a></li>
  52.     <li><a href="#runtime">Run-time errors</a></li>
  53.     <li><a href="#vsdebug">Debugging in Visual Studio 2005</a></li>
  54.     <li><a href="#debugperf">Debugging performance issues</a></li>
  55.     <li><a href="#tracing">Event tracing</a></li>
  56.     <li><a href="#hybrid">Debugging hybrid applications</a></li>
  57.     <li><a href="#security">Security</a></li>
  58.     <li><a href="#help">Getting help</a></li>
  59. </ul>
  60. <p>If your Microsoft® Expression Blend™ application does not behave the way that 
  61. you expect, or if errors occur when you try to build your application, there is a bug 
  62. in your application. It can be difficult to understand what is causing a bug or where 
  63. in your application it exists, but it helps to understand the types of bugs that you 
  64. might encounter.</p>
  65. <a name="syntax"></a><h2>Syntax errors</h2>
  66. <p>
  67. When you build your application, any syntax errors are displayed in the
  68. <strong>Errors</strong> 
  69. tab of the <strong>Results</strong> panel of Expression Blend, or in the <strong>Error 
  70. List</strong> panel in Microsoft® Visual Studio® 2005.</p>
  71. <p>
  72. Syntax errors occur if your Extensible Application Markup Language (XAML) or code does not follow the 
  73. formatting rules of the language. The description of the error 
  74. can help you understand how to fix it. The description also specifies the name of the 
  75. file and the line number where the error occurs. Some common causes of syntax 
  76. errors are as follows:</p>
  77. <ul>
  78. <li>A keyword has been misspelled or the capitalization is wrong.</li>
  79. <li>Quotation marks are missing around strings of text.</li>
  80. <li>A XAML element is missing a closing tag.</li>
  81. <li>A XAML element exists in a location where it is not allowed. You can avoid 
  82. these errors by editing your documents in <strong>Design</strong> view in Expression 
  83. Blend, or in Visual Studio 2005 with the extensions for .NET Framework 3.0 
  84. installed. The extensions can be downloaded from <a target="_blank" href="http://go.microsoft.com/fwlink/?linkid=74081">MSDN</a>. </li>
  85. <li>In a code file, a function or method call does not include the required 
  86. parameters. For example, the <code>MessageBox.Show()</code> method must have at 
  87. least one parameter, such as a string, <code>MessageBox.Show("Hello")</code>.</li>
  88. <li>In a code file, a variable of one type is being assigned to a different 
  89. type. For example, the <code>MessageBox.Show()</code> method can have a string argument, but it cannot have an integer argument.</li>
  90. <li>In C#, a method that does not need arguments might not have braces at the 
  91. end. For example, <code>this.InitializeComponent;</code> will cause a syntax error because 
  92. the correct line is <code>this.InitializeComponent</code>()<code>;</code>.</li>
  93. </ul>
  94. <p>
  95. For information about XAML syntax, see the overview topics for individual 
  96. controls listed in the "Control Library" topic in the Windows Presentation Foundation 
  97. (WPF) section  
  98. on <a target="_blank" href="http://go.microsoft.com/fwlink/?linkid=74081">MSDN</a>. For information about programming syntax, you can search on MSDN for 
  99. keywords in your code. </p>
  100. <a name="compile"></a><h2>Compilation errors</h2>
  101. <p>When you build your application, any compilation errors are displayed 
  102. in the
  103. <strong>Errors</strong> 
  104. tab of the <strong>Results</strong> panel of Expression Blend, or in the <strong>Error 
  105. List</strong> panel in Visual Studio 2005.</p>
  106. <p>Compilation errors occur when the compilation system of Expression 
  107. Blend or Visual Studio 2005 cannot find something that your project requires. 
  108. For example, if your project is missing a reference to the WPF assemblies, you might get an error such as "The name 
  109. 'Window' does not exist in namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'". 
  110. If you get this error, you can click <strong>Add Reference</strong> on the
  111. <strong>Project</strong> menu to add references to the following WPF assemblies 
  112. in the C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0 folder:</p>
  113. <ul><li>PresentationCore.dll</li>
  114.     <li>PresentationFramework.dll</li>
  115.     <li>WindowsBase.dll</li></ul>
  116.     <p>If you still receive errors such as "The name '<em><member></em>' does not exist 
  117.     in the current context.", there might be another assembly reference missing, 
  118.     or you might need to add a <strong>using</strong> (C#) or <strong>Imports</strong> 
  119.     (Visual Basic .NET) statement to your code for the missing namespace. To find out which 
  120.     assembly or namespace is required, see the MSDN reference topic for the 
  121.     member that is causing the error.</p>
  122. <p>Some other common causes for compilation errors are as follows:</p>
  123. <ul>
  124. <li>A keyword has been misspelled or the capitalization is wrong.</li>
  125. <li>A class is not referenced properly in your application. For example, if your 
  126. application uses a custom class which is implemented 
  127. in a separate .cs or .vb code file with its own namespace, any document in your 
  128. application that uses the custom class needs to include 
  129. a line like the following, where <code>FullyQualifiedNamespace</code> is the namespace in the 
  130. code file: <pre><code>xmlns:SampleNamespace="clr-namespace:FullyQualifiedNamespace"</code></pre></li>
  131. <li>The compiler options are not set properly, or your system is not capable of 
  132. building Microsoft® .NET Framework–based applications. If you have the  Microsoft .NET Framework 3.0 installed, 
  133. and you 
  134. are building your application by using Expression Blend or Visual Studio 2005, this 
  135. should not be an issue.</li>
  136. <li>A file has not been saved before trying to build the project. For example, 
  137. if you use the <strong>Events</strong> panel  
  138.     <img class="buttonart" alt="Events button" src="../main/images/icons/properties/properties_displayevents_on_16x16.png" /> 
  139. of Expression Blend to generate a new event handler method in the code-behind 
  140. file (thus opening the code-behind file in Visual Studio), and then try to build 
  141. the project in Expression Blend without first saving the code-behind file, you 
  142. will get an error saying that your project does not contain a definition for the 
  143. event handler.</li>
  144. </ul>
  145. <a name="runtime"></a><h2>Run-time errors</h2>
  146. <p>You have a run-time error if 
  147. your application builds but it behaves in an unexpected way when you run it (by 
  148. pressing F5 in Expression Blend). Run-time errors are the most difficult to 
  149. identify because they involve errors in logic. Sometimes, you can fix run-time 
  150. errors by trying out different changes in your XAML or code until you understand 
  151. what is going on behind the scenes. However, it is faster to actually watch what 
  152. is going on behind the scenes by stepping through your code line by line as the 
  153. application is running. For more information, see <a href="#vsdebug">Debugging in Visual Studio 2005</a> 
  154. later in this topic.</p>
  155. <p>Some common causes of run-time errors are as follows:</p>
  156. <ul>
  157. <li>XAML elements are not laid out properly, or the wrong panel element is being used to contain other elements. To learn about layout, see 
  158. <a href="../layout/essentials_layout.htm">The Layout System</a> in 
  159. this User Guide, or see
  160. "The Layout 
  161. System" and
  162. "Alignment, Margins, and Padding Overview" in the WPF section  
  163. on <a target="_blank" href="http://go.microsoft.com/fwlink/?linkid=74081">MSDN</a>.</li>
  164. <li>A XAML element is not hooked up to the correct event handler. This can 
  165. happen if you create many event handler methods and then assign the wrong one to 
  166. the XAML element. To see which event handlers are assigned to a XAML element in 
  167. Expression Blend, select the element under <strong>Objects and Timeline</strong> in the <strong>
  168. Interaction</strong> panel, and then in the <strong>Properties</strong> panel, 
  169. click the <strong>Events</strong> button. For more information, see
  170. <a href="../animation/anim_eventhandling.htm">Event handling</a> in this User Guide.</li>
  171. <li>An animation trigger in Expression Blend is not set properly. For example, 
  172. animation storyboards must be started in any trigger if you want to be able to stop or pause them after the application is 
  173. loaded. (All animation storyboards are started in the <strong>Window.Loaded</strong> 
  174. trigger by default, but you can change that.) For more information, see 
  175. <a href="../animation/essentials_animation.htm">Essentials of Animation</a> in 
  176. this User Guide. For an example of animation triggers, see
  177. <a href="../animation/anim_properties.htm">Create a simple animation</a>, or see 
  178. the topics under the <strong>Try it!</strong> section in
  179. <a href="../controls/simplestyles/dc_simplestyles.htm">Simple styles</a>.</li>
  180. <li>In a code file, a variable references an object that does not yet exist. For 
  181. example, in a code-behind file, you can not reference a XAML object before the line 
  182. <code>this.InitializeComponent();</code>, otherwise you will get a <strong>XamlParseException</strong> 
  183. error.</li>
  184. <li>In a code file, assumptions are made that make your application progress 
  185. down an unexpected code path. This situation benefits most from stepping through 
  186. your code while debugging your application in Visual Studio 2005. For more 
  187. information, see <a href="task_debugginginvs.htm">Debugging Expression Blend 
  188. applications in Visual Studio</a> in this User Guide.</li>
  189. <li>In a code-behind file, user interface (UI) updates are executed on the same thread as other 
  190. programming logic that should be performed on a separate thread. For example, if you create an event handler method that 
  191. updates the text that is displayed in a <strong>Label</strong>, performs some other calculations, and then updates the 
  192. text in the same <strong>Label</strong> again before the event handler method 
  193. completes, you will only see the last update. This is because the rendering of 
  194. your UI occurs at the end of your event handler method and all processing is 
  195. done on the same thread, so your application cannot take time out during the 
  196. execution of your method to update the UI. For information about how to write 
  197. WPF applications that have multiple UI updates and calculations, see
  198. "Threading Model" 
  199. in the WPF section  
  200. on <a target="_blank" href="http://go.microsoft.com/fwlink/?linkid=74081">MSDN</a>
  201. . </li>
  202. <li>In an event handler method in a code-behind file, UI elements or their 
  203. properties are referenced before they are available. For example, in 
  204. your Window1() constructor method, you will not be able to access UI elements 
  205. yet. In an OnInitialized() event handler method, you can access UI elements, but you cannot examine properties like ActualWidth because the UI elements have not been laid 
  206. out yet. In an OnLoaded() event handler method, you can do anything you need to 
  207. do with UI elements that exist in your XAML document. For more information, see 
  208. "Object Lifetime Events" 
  209. in the WPF section  
  210. on <a target="_blank" href="http://go.microsoft.com/fwlink/?linkid=74081">MSDN</a>
  211. . For a 
  212. list of events and when they occur, see the
  213. <a href="../reference/reference_events.htm">
  214.     Events quick reference</a> in this User Guide.</li>
  215. </ul>
  216. <a name="vsdebug"></a><h2>Debugging in Visual Studio 2005</h2>
  217. <p>Expression Blend is a design tool for creating rich user interfaces and Windows®-based applications 
  218. that make use of WPF features. You can use Visual Studio 2005, which is also used to build 
  219. Windows-based applications, to open, build, and debug Expression Blend projects. 
  220. If you are having trouble debugging your application by using the <strong>Test</strong> 
  221. (F5) feature of Expression Blend, you can use Visual Studio 2005 to obtain 
  222. detailed error messages about run-time errors. For more information, see
  223. <a href="task_debugginginvs.htm">Debugging Expression Blend 
  224. applications in Visual Studio</a> in this User Guide.</p>
  225.     <table>
  226.     <tbody>
  227.     <tr>
  228.         <td>
  229.         <img border="0" src="../main/images/icons/icon_tip.png" width="32" height="32" alt="Tip" /></td>
  230.         <td>To create new XAML applications and XAML Browser applications (XBAPs) in 
  231.         Visual Studio 2005, you need to install the extensions for .NET 
  232.         Framework 3.0. These can be downloaded from <a target="_blank" href="http://go.microsoft.com/fwlink/?linkid=74081">MSDN</a>. 
  233.         (You do not need the extensions to debug XAML applications 
  234.         that were created with Expression Blend.)</td>
  235.     </tr>
  236.     </tbody>
  237.     </table>
  238.  
  239. <a name="debugperf"></a><h2>Debugging performance issues</h2>
  240. <p>WPF provides a suite of performance assessment tools that allow you to 
  241. analyze the run-time behavior of your application and determine how you can 
  242. improve performance. For more information, see
  243. "Performance 
  244. Profiling Tools for WPF" and
  245. "Optimizing WPF 
  246. Application Performance" in the WPF section  
  247. on <a target="_blank" href="http://go.microsoft.com/fwlink/?linkid=74081">MSDN</a>
  248. .</p>
  249. <a name="tracing"></a><h2>Event tracing</h2>
  250. <p>Experienced .NET programmers can add code to their WPF applications to 
  251. trigger custom debugging events that help them to debug more complicated bugs. This feature is called 
  252. Event Tracing for Windows (ETW). The WPF Event Trace profiling tool uses ETW for 
  253. event logging. For more information, see "Event Tracing"  and the
  254. "PresentationTraceSources" class in the WPF section  
  255. on <a target="_blank" href="http://go.microsoft.com/fwlink/?linkid=74081">MSDN</a>.</p>
  256. <a name="hybrid"></a><h2>Debugging hybrid applications</h2>
  257. <p>If you have an application that uses both WPF and another technology like 
  258. Windows Forms programming, you may experience problems such as unexpected 
  259. overlapping behavior, scaling behavior, control focus issues, and so on. For 
  260. information that can help you debug hybrid applications, see "Troubleshooting Hybrid Applications in the WPF section  
  261. on <a target="_blank" href="http://go.microsoft.com/fwlink/?linkid=74081">MSDN</a>.</p>
  262. <a name="security"></a><h2>Security</h2>
  263. <p>While being debugged, your application has the same security permissions that 
  264. it has when another person uses it. For more information, see <a href="concept_deployment.htm">Deploying and publishing Expression Blend applications</a> 
  265. in this User Guide. For more information about WPF application security, see
  266. "Security" in the WPF section  
  267. on <a target="_blank" href="http://go.microsoft.com/fwlink/?linkid=74081">MSDN</a>.</p>
  268. <a name="help"></a><h2>Getting help</h2>
  269. <p>If you need more help debugging your Expression Blend application, you can 
  270. search on <a target="_blank" href="http://go.microsoft.com/fwlink/?linkid=83197">Windows Presentation Foundation Forum</a> for posts related your issue or post a question.</p>
  271.  
  272. </div>
  273.  
  274. </div>
  275.  
  276. </html>